package com.example.demo.controller;


import com.example.demo.entity.PayloadEntity;
import com.example.demo.result.Result;
import com.example.demo.result.ResultUtil;
import com.example.demo.service.PayLoadService;
import com.example.demo.service.impl.PayLoadServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class PayLoadController {
    @Autowired
    public PayLoadServiceImpl payLoadService;

    @RequestMapping("/payload")
    public Result payLoad(@RequestBody PayloadEntity payloadEntity){
        String imgUrl = payloadEntity.getSerialNumber() + ".jpg";
        if (payLoadService.successPayLoad(payloadEntity.getBase64str(),payloadEntity.getSerialNumber(),imgUrl)) {
            return ResultUtil.success(imgUrl);
        }else{
            return ResultUtil.error("修改失败");
        }
    }

}
